all files / bottomNav/ bottomNav.vue

28.57% Statements 6/21
22.22% Branches 4/18
12.5% Functions 1/8
11.76% Lines 2/17
1 branch Ignored     
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53  1×                                                                                                      
 
import abstractButton from '../internal/abstractButton'
export default {
  name: 'mu-bottom-nav',
  props: {
    shift: {
      type: Boolean,
      default: false
    },
    value: {}
  },
  methods: {
    handleItemClick (value, item) {
      if (value !== this.value) {
        this.$emit('change', value)
      }
      this.$emit('itemClick', item)
    },
    setChildrenInstance () {
      var children = this.$slots.default
      children.forEach((vNode) => {
        if (vNode && vNode.child && vNode.child.isBottomNavItem) {
          vNode.child.bottomNav = this
        }
      })
    }
  },
  mounted () {
    this.setChildrenInstance()
  },
  updated () {
    var children = this.$slots.default
    children.forEach((vNode) => {
      if (vNode && vNode.child && vNode.child.isBottomNavItem) {
        vNode.child.bottomNav = this
      }
    })
  },
  render (h) {
    return h(abstractButton, {
      class: ['mu-bottom-nav', this.shift ? 'mu-bottom-nav-shift' : undefined],
      props: {
        disableTouchRipple: !this.shift,
        centerRipple: false,
        wrapperClass: 'mu-bottom-nav-shift-wrapper',
        containerElement: 'div',
        rippleOpacity: 0.3
      }
    }, this.$slots.default)
  }
}